package cn.com.capinfo.ea.example.demo.domain
import cn.com.capinfo.ea.core.annotation.Title
import com.fasterxml.jackson.annotation.JsonFormat
import com.fasterxml.jackson.annotation.JsonIgnore
import com.fasterxml.jackson.annotation.JsonIgnoreProperties
import grails.gorm.annotation.Entity
import net.sf.ehcache.pool.Size
import org.springframework.format.annotation.DateTimeFormat

@Entity
@Title(zh_CN = "作者")
@JsonIgnoreProperties(["errors", "metaCNlass", "dirty", "attached", "dirtyPropertyNames","handler","target","session","entityPersisters","hibernateLazyInitializer","initialized","proxyKey","children"])
class Author {
    @Title(zh_CN = "名称")
    String name
    @Title(zh_CN = "年龄")
    int age
    @Title(zh_CN = "生日")
    @JsonFormat(pattern = "yyyy-MM-dd",timezone="GMT+8")
    @DateTimeFormat(pattern="yyyy-MM-dd") //with spring mvc
    Date birthday


    static hsaMany = [books:Book]


    static constraints = {
        name(blank:false,unique: true,size:0..100)
        birthday()
        age(size:100)
    }
    static mapping = {

    }

    String toString(){
        return name
    }
}